<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/6/14 0014
 * Time: 下午 13:24
 */

use yii\helpers\Html;

$activity = $this->context->activity;
$this->title = $activity->title;
?>

<style type="text/css">

</style>

<?= \frontend\widgets\Swiper::widget(['model' => $activity]) ?>

<div class="container-fluid">


    <?= \frontend\widgets\CounterDown::widget(['activity' => $activity]) ?>

    <div class="r4_card">
        <p>
            <?= Yii::t('app.c2', 'Activity Start Time {s1} End Time {s2}', [
                's1' => $activity->start_at,
                's2' => $activity->end_at,
            ]) ?>
        </p>
        <p><?= Yii::t('app.c2', 'Activity Rule Can Vote {s1} Once Day', [
                's1' => $activity->vote_number_limit,
            ]) ?></p>
    </div>

    <?= \frontend\widgets\PlayerList::widget([
            'activity' => $activity,
            'pageSize' => 4
    ]) ?>


</div>


<script type="text/javascript">
    wx.ready(function () {   //需在用户可能点击分享按钮前就先调用
        //shareData 参数记得为字符串类型
        var shareData = {
            title: '<?= $activity->title ?>',
            desc: '<?= Html::encode($activity->content) ?>',//这里请特别注意是要去除html
            link: '<?= Yii::$app->request->hostInfo . Yii::$app->request->url ?>',//域名必须JS安全域名
            imgUrl: '<?= $activity->getThumbnailUrl() ?>',
            success: function () {

            },
            cancel: function () {
                console.log('cancel')
            }
        };

        if (wx.onMenuShareAppMessage) { //微信文档中提到这两个接口即将弃用，故判断
            wx.onMenuShareAppMessage(shareData);//1.0 分享到朋友
            wx.onMenuShareTimeline(shareData);//1.0分享到朋友圈
        } else {
            wx.updateAppMessageShareData(shareData);//1.4 分享到朋友
            wx.updateTimelineShareData(shareData);//1.4分享到朋友圈
        }

    });
</script>